Skip to content

Fix deprecated datetime.utcfromtimestamp() calls#3410

Open
apoorvdarshan wants to merge 1 commit intospotify:masterfrom
apoorvdarshan:fix/deprecation-utcfromtimestamp
Open

Fix deprecated datetime.utcfromtimestamp() calls#3410
apoorvdarshan wants to merge 1 commit intospotify:masterfrom
apoorvdarshan:fix/deprecation-utcfromtimestamp

Conversation

@apoorvdarshan
Copy link

@apoorvdarshan apoorvdarshan commented Mar 18, 2026

Summary

Changes

  • luigi/parameter.py: Replace datetime.datetime.utcfromtimestamp(0) with datetime.datetime(1970, 1, 1) — equivalent and avoids the deprecation entirely
  • luigi/tools/range.py: Replace datetime.utcfromtimestamp(ts) with datetime.fromtimestamp(ts, tz=timezone.utc).replace(tzinfo=None) — converts via UTC then strips tzinfo to keep naive datetime compatibility

Test plan

  • Verified both replacements produce identical values to the original calls
  • Verified returned datetimes are naive (no tzinfo) to maintain backwards compatibility
  • Existing test suite passes

Fixes spotify#3356 and spotify#3317. `datetime.utcfromtimestamp()` is deprecated
since Python 3.12 and scheduled for removal. Replace with
timezone-aware alternatives that preserve naive UTC datetime behavior
for backwards compatibility.
@apoorvdarshan apoorvdarshan requested review from a team and dlstadther as code owners March 18, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeprecationWarning parameter.py

1 participant